/** api集合 */
// var host = 'http://testmedia.heardtech.com';
var host = 'http://media.soundems.com';
var apiCollect = {
	apiChooseMedia: host + '/Post/ChoseMedia', // 切换主体
	apiAddExpectation: host + '/Post/MediaExpect', // 增加期待值
	apiCheckExpectation: host + '/Post/CountExpect', // 查询期待值
	apiCharge: host + '/Post/PayBalance', // 充值接口
	apiChargeCheck: host + '/Post/ajaxBalanceIspay', // 查询充值状态
	apiGetVerification: host + '/Post/GetCode', // 获取验证码
	apiRegister: host + '/Post/DoRegister', // 注册账号
	apiRegisterObject: host + '/Post/PostRegistered', // 注册主体
	apiLogin: host + '/Post/DoLogin', // 账号登录
	apiWXLogin: host + '/Post/WechatRegister', // 微信扫码登录
	apiGetArticleContent: host + '/Post/GetWebcontent', // 获取网址文章内容
	apiGetDocContent: host + '/Get/openword', // 获取oss文档内容
	apiCreateOrder: host + '/Post/CreateOrder', // 创建订单
	apiDeleteOrder: host + '/Post/DeleteOrder', // 删除订单
	apiGetWXQR: host + '/Post/PayOrder', // 获取微信支付二维码
	apiGetPayStatus: host + '/Post/ajaxOrderIspay', // 获取订单支付状态
	apiOrderList: host + '/Post/MediaOrder', // 订单列表
	apiArticleContent: host + '/Post/Contentinfo', // 获取文章内容
	apiReward: host + '/Post/PayReward', // 打赏接口
	apiRewardStatus: host + '/Post/ajaxRewardIspay', // 打赏状态
	apiOrderCmtInfo: host + '/Post/GetScoreorder', // 获取订单评价信息
	apiOrderCmt: host + '/Post/ScoreOrder', // 评价订单
	apiOrderReject: host + '/Post/RejectOrder', // 驳回订单
	apiMediaInfo: host + '/Post/Mediainfo', // 获取主体信息
	apiWXUnbind: host + '/Post/wxUnbind', // 解绑微信
	apiWXBind: host + '/Post/WxBinding', // 绑定微信
	apiPWUpdate: host + '/Post/UpdatePassword', // 修改密码
	apiMediaDefault: host + '/Post/UpdateMedialike', // 修改主体默认偏好
	apiMediaList: host + '/Post/SelectMedia', // 主体列表
	apiQiniu: host + '/Common/uptoken_image', // 获取七牛上传参数
	apiQiniuUpToken:'http://qiniu.heardtech.com/uptoken2.php',
	apiMediaUpdate: host + '/Post/UpdateMedia', // 修改主体信息
	apiEmailUpdate: host + '/Post/UpdateEmail', // 修改邮箱
	apiGetBalance: host + '/Post/GetBalance', // 查询余额
	apiGetIncome: host + '/Post/GetIncome',   //我的钱包
	apiCreateSignOrder:host + '/Post/CreateSignOrder',  //创建签约订单
	apiShare: host + '/Post/Share' ,   //分享接口
    apiBillBalance: host + '/Post/GetBalance' ,   //发票余额
    apiInvoice: host + '/Post/PostInvoice',  //发票表单
	apiPaySignOrder: host + '/Post/PaySignOrder',  //签约付款
    apiGetMusicType: host + '/Bgm/GetClass' ,//获取音乐列表类型
    apiGetBgmList: host + '/Bgm/GetBgmList',
    apiPostMediaAdd:host+ '/Bgm/mediaaddmusic',
    // 获取自选主播列表
    apiPostChoseOrder: host + '/Post/ChoseOrder',
    // 选择主播列表
    apiPostSelectChoseUse: host + '/Post/selectchoseuser',
    apiPostFeedBack: host + '/Post/FeedBack',
    apiPostPasswordFind: host + '/Post/PasswordFind',

};

//监听 onpaste鼠标右键粘贴或 Ctrl + V
// function getSelectionBoundary(el, start) {
//     var property = start ? "selectionStart" : "selectionEnd";
//     var originalValue, textInputRange, precedingRange
//         , pos, bookmark, isAtEnd;
//
//     if(typeof el[property] == "number") {
//         return el[property];
//     }
//     else if(document.selection && document.selection.createRange) {
//         el.focus();
//         var range = document.selection.createRange();
//         if(range) {
//             if(document.selection.type == "Text") {
//                 range.collapse(!!start);
//             }
//             originalValue = el.value;
//             textInputRange = el.createTextRange();
//             precedingRange = el.createTextRange();
//             pos = 0;
//             bookmark = range.getBookmark();
//             textInputRange.moveToBookmark(bookmark);
//             if(/[\r\n]/.test(originalValue)) {
//                 try {
//                     range.move("character", 1);
//                     isAtEnd = (range.parentElement() != el);
//                 }
//                 catch(ex) {
//                     isAtEnd = true;
//                 }
//                 range.moveToBookmark(bookmark);
//                 if(isAtEnd) {
//                     pos = originalValue.length;
//                 }
//                 else {
//                     textInputRange.text = " ";
//                     precedingRange.setEndPoint("EndToStart",
//                         textInputRange);
//                     pos = precedingRange.text.length - 1;
//                     textInputRange.moveStart("character", -1);
//                     textInputRange.text = "";
//                 }
//             }
//             else {
//                 precedingRange.setEndPoint("EndToStart", textInputRange);
//                 pos = precedingRange.text.length;
//             }
//             return pos;
//         }
//     }
//     return 0;
// }
//
// function getInputSelection(ele) {
//     var start = getSelectionBoundary(ele, true),
//         end = getSelectionBoundary(ele, false);
//     return {
//         start: start,
//         end: end,
//         length: end - start,
//         text: ele.value.slice(start, end)
//     };
// }
//
// function detectPaste(ele, callback) {
//     ele.onpaste = function() {
//         var sel = getInputSelection(ele);
//         var initialLength = ele.value.length;
//         window.setTimeout(function() {
//             var val = ele.value;
//             var pastedTextLength =
//                 val.length - (initialLength - sel.length);
//             var end = sel.start + pastedTextLength;
//             callback({
//                 start: sel.start,
//                 end: end,
//                 length: pastedTextLength,
//                 text: val.slice(sel.start, end),
//                 replacedText: sel.text
//             });
//         }, 1);
//     };
// }
/*** 获取文章内容 begin */
// 获取url参数
function GetQueryString(name) {
     var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
     var r = window.location.search.substr(1).match(reg);
     if(r!=null)return  unescape(r[2]); return '';
}

function isFloat(n) {
  return n % 1 !== 0;
}

function headtip(){
	$('.headtip').show();
	$('.headtip').stop().animate({'top':'60px'},400,function(){
		$('.headtip').delay(2000).animate({'top':'0px'},400)
	});
}

// 错误提示
// 代替上面的headtip()
// 可修改错误内容
var headtipObj = {
	show: function (info) {
		$('.headtip').text(info).show();
		$('.headtip').stop().animate({'top':'60px'},400,function(){
			$('.headtip').delay(2000).animate({'top':'-50px'},400)
		});
	}
};
// 错误提示
// 代替上面的headtip()
// 可修改错误内容
var headtipObj2 = {
	show: function (info) {
		$('.headtip2').text(info).show();
		$('.headtip2').stop().animate({'top':'60px'},400,function(){
			$('.headtip2').delay(2000).animate({'top':'-50px'},400)
		});
	}
};

/** #common-confirm-box事件  */
var commonConfirmBox = {
	data: {
		title: '彻底删除',
		text: '即将彻底删除文件即将彻底删除文件即将彻底删除文件即将彻底删除文件',
		confirmCallback: function () {

		}
	},
	init: function () {
		var _this = this;
		$('#common-confirm-box').click(function () {
			_this.hide();
		});
		$('#common-confirm-box .dialog').click(function (ev) {
			ev.stopPropagation();
		});
		$('#common-confirm-box .close').click(function(ev) {
			ev.preventDefault();
			_this.hide();
		});
		$('#common-confirm-box .btn.btn-ok').click(function(ev) {
			ev.preventDefault();
			if (typeof _this.data.confirmCallback == 'function') _this.data.confirmCallback();
		})
	},
	show: function (data, callback, confirmCallback, cancelCallback) {
		if (data.title) this.data.title = data.title;
		if (data.text) this.data.text = data.text;
		if (typeof callback == 'function') callback();
		if (confirmCallback) {
			this.data.confirmCallback = confirmCallback;
		} else {
			this.data.confirmCallback = function () {
			};
		}
		if (cancelCallback) {
			this.data.cancelCallback = cancelCallback;
		} else {
			this.data.cancelCallback = function () {};
		}
		this.setTitle();
		this.setText();
		$('#common-confirm-box').removeClass('hide');
	},
	hide: function () {
		if (typeof this.data.cancelCallback == 'function') this.data.cancelCallback();
		$('#common-confirm-box').addClass('hide');
	},
	setTitle: function () {
		$('#common-confirm-box .header-text').text(this.data.title);
	},
	setText: function () {
		$('#common-confirm-box .dialog-body').text(this.data.text);
	}
};
commonConfirmBox.init();

// 点击上传
var uploader = {
	status: 0, 	// 0 未开始， 1 已输入 2 上传中 3 完成
	api: 'http://testoss.heardtech.com/demo.php',
	$text: $('#mask_up_file').siblings('.mask_upload_text'),
	fileName: '',
	docTitle: '',
	init: function () {
		this.bindBtn();
		this.bindChange();
		this.bindRedirect();
	},
	bindRedirect: function () {
		var _this = this;
		$('.mask_wrap .mask_up .mask_c_btn').click(function () {
			var $this = $(this);
			if ($this.hasClass('btn-black')) {
				// window.location.href = './speeDdubbing.html?file=' + encodeURIComponent(_this.fileName) +
				// 	"&title=" + encodeURIComponent(this.docTitle);
				var url = './speeDdubbing.html?file=' + encodeURIComponent(encodeURIComponent(_this.fileName)) +
					"&title=" + encodeURIComponent(encodeURIComponent(_this.docTitle));
				window.location.href = url;
			}
		})
	},
	bindBtn: function () {
		$('#mask_up_file').click(function () {
			$('#upload-word').trigger('click');
		})
	},
	bindChange: function () {
		var _this = this;
		if (!document.getElementById('upload-word')) return;
			document.getElementById('upload-word').addEventListener('change', function (e) {
				_this.status = 1;
				var file = e.target.files[0];
				var timeStamp = new Date().getTime();
			var storeAs = timeStamp + '.docx';//这个用于请求获取文章内容的
				_this.fileName = storeAs;
				_this.docTitle = file.name.substring(0, file.name.lastIndexOf('.'));
			OSS.urllib.request(_this.api, {method: 'GET'}, function (err, response) {
					_this.status = 2;
					_this.$text.text('上传中');
			if (err) {
			  return alert(err);
			}
			try {
			  result = JSON.parse(response);
			} catch (e) {
			  return alert('parse sts response info error: ' + e.message);
			}
			console.log(result);
			var client = new OSS.Wrapper({
			  accessKeyId: result.Credentials.AccessKeyId,
			  accessKeySecret: result.Credentials.AccessKeySecret,
			  stsToken: result.Credentials.SecurityToken,
			  endpoint: 'oss-cn-beijing.aliyuncs.com',
			  bucket: 'heard-word'
			});
			client.multipartUpload(storeAs, file).then(function (result) {
						console.log('上传成功:', result);
						_this.status = 3;
						_this.$text.text(file.name);
						_this.fileName = storeAs;
						$('.mask_wrap .mask_up .mask_c_btn').addClass('btn-black');
			}).catch(function (err) {
			  console.log(err);
			});
		  });
		});
	}
};
uploader.init();

// 网址获取
webGetter = {
	api: apiCollect.apiGetArticleContent,
	$input: $('.mask_midle_inp'),
	$btn: $('.mask_w .mask_c_btn'),
	url: '',
	init: function () {
		this.bindBtn();
		this.bindChange();
	},
	bindBtn: function () {
		var _this = this;
		_this.$btn.click(function () {
			if (_this.$btn.hasClass('btn-black')) {
				// 触发事件
				$.post(_this.api, {
					url: _this.url
				}, function (data) {
					if (data.code == '000000') {
						window.location.href = 'speeDdubbing.html?file=' + encodeURIComponent(encodeURIComponent(data.data.txt))
							+ '&title=' + encodeURIComponent(encodeURIComponent(data.data.title));
					} else {
						headtipObj.show(data.message);
					}
				})
			}
		})
	},
	bindChange: function () {
		var _this = this;
		//测试代码
        // _this.$input.on('input propertychange',function(){
        //     alert(1)
        // });
		_this.$input.on('keyup paste change', function () {
			// console.log('paste');
			setTimeout(function () {
				var value = _this.$input.val();
				_this.url = value;
				//判定输入网址 内容而替换 btn颜色
                if (value.length != 0) {
					_this.$btn.addClass('btn-black');
				} else {
					_this.$btn.removeClass('btn-black');
				}
			}, 0)
		});
	}
};

webGetter.init();
var data_id =''
/* 切换主体 */
var pressSelect = {
	$container: $('#popup-change-press'),
	selectedId: '',	// 要切换的主体id
	// apiChange: 'http://testmedia.heardtech.com/Post/ChoseMedia',
	apiChange: apiCollect.apiChooseMedia,
	// apiData: 'http://testmedia.heardtech.com/Post/SelectMedia',
	apiData: apiCollect.apiMediaList,
	init: function () {
		this.bindClose();
		this.bindSelect();
		this.bindConfirm();
	},
	// 显示主体弹窗
	show: function (data) {
		var _this = this;
		$.post(_this.apiData, {
			wid: localStorage.getItem('wid')
		}, function (data) {
			if (data.code == '000000') {

				_this.$container.removeClass('hide');
				_this.$container.find('.press-list').html(_this.render(data.data));
			} else {
				headtipObj.show(data.message);
			}
		})
	},
	// 渲染备选主体选项
	render: function (data) {
		var html = '';
		for (var i = 0;i < data.length; i++) {
			html += this.renderItem(data[i]);
		}
		return html;
	},
	renderItem: function (item) {
		var active = " active"
        var html = "<li class='press-wrapper"
        if(item.token_key == localStorage.getItem('token')){
        	html += active
        	data_id = item.token_key
        }
        html += "' data-id="+ item.token_key +"><div class='press-head'><img src="+item.media_pic+" alt=''></div><div class='press-body'><div class='press-title'>"+item.media_name+"</div><div class='press-info'>"+item.media_message+"</div></div>"
        html += "<div class='press-footer'"
        if(item.token_key == localStorage.getItem('token')){
        	html += " style='display:block'>"
        }
        html += "<span>订单</span><span> / </span><span> 设置随主体切换 余额互通</span></div></li>";
		return html;
		data_id = item.token_key
	},
	// 确认操作
	bindConfirm: function () {
		var bool = false;
		var _this = this;
		_this.$container.find('.btn.btn-confirm').addClass('active').click(function () {
			if (_this.selectedId && !bool) {
				bool = true;
				var id = _this.selectedId;
				$.post(_this.apiChange, {
					wid: localStorage.getItem('wid'),
					token: id
				}, function (data) {
					if (data.code == "000000") {
						localStorage.setItem('token', id);
						bool = false;
						// personInfo.updateDOM(data.data);
						_this.close();
						window.location.reload();
					} else {
						headtipObj.show(data.messgae);
					}
				})
			}else{
				bool = true;
				var id = data_id;
				$.post(_this.apiChange, {
					wid: localStorage.getItem('wid'),
					token: data_id
				}, function (data) {
					if (data.code == "000000") {
						localStorage.setItem('token', id);
						bool = false;
						// personInfo.updateDOM(data.data);
						_this.close();
						window.location.reload();
					} else {
						headtipObj.show(data.messgae);
					}
				})
			}
		})
	},
	bindSelect: function () {
		var _this = this;
		$('#popup-change-press > .inner').delegate('.press-wrapper', 'click', function (ev) {
			console.log('wrapper click');
			var $this = $(this);
			$this.addClass('active').siblings().removeClass('active');
			_this.selectedId = $this.data('id');
			_this.$container.find('.btn.btn-confirm').addClass('active');
			_this.$container.find('.popup-footer span.tip').text('已选择：' + $this.find('.press-title').text());
			$this.hasClass('active')? $this.children('.press-footer').show().parent('li').siblings().children('.press-footer').hide() : alert(1)
		})
	},
	bindClose: function () {
		var _this = this;
		this.$container.unbind('click').click(function (ev) {
			console.log(ev);
			ev.stopPropagation();
			_this.close();
		});
		this.$container.find('.close').click(function () {
			_this.close();
		});
		this.$container.find('.inner').unbind('click').click(function (ev) {
			ev.stopPropagation();
			// return false;
		})
	},
	// 关闭弹窗
	close: function () {
		this.selectedId = '';
		this.$container.find('.btn.btn-confirm').removeClass('active');
		this.$container.find('.popup-footer span.tip').text('');
		this.$container.addClass('hide');
	}
};
// pressSelect.init();

/* 左上角个人设置选项 */
var personInfo = {
	$container: $('.boxShow.mine'),
	// api: 'http://testmedia.heardtech.com/Post/Mediainfo',
	api: apiCollect.apiMediaInfo,
	callback: function (data) {
	},
	init: function (updateDOMCallback, ajaxCallbackOnce) {
		if (typeof callback == 'function') this.callback = updateDOMCallback;
		this.pullData(ajaxCallbackOnce);
		this.bindLogout();
		this.bindSwitch();
		this.bindHelp();
	},
	// 切换主体按钮
	bindSwitch: function () {
		// 切换主体按钮
		$('.boxShow.mine').delegate('.first-line .font', 'click', function (e) {
			pressSelect.show();
		});
		$('.boxShow.mine').delegate('.token-switch', 'click', function (e) {
			pressSelect.show();
		})
	},
	bindHelp: function () {
		$('.boxShow.mine').delegate('.help-item', 'click', function (e) {
			headtipObj2.show('请添加客服获得帮助');
		})
	},
	// 退出按钮绑定
	bindLogout: function () {
		this.$container.delegate('.logout', 'click', function (e) {
			e.stopPropagation();
			if(localStorage.getItem('token')) localStorage.removeItem('token');
			if(localStorage.getItem('wid')) localStorage.removeItem('wid');
			window.location.href="logIn/index.html";
		})
	},
	// 获取数据
	pullData: function (callback) {
		var _this = this;
		$.post(_this.api, {
			token: localStorage.getItem('token')
		}, function (data) {
            if (data.code == '000000') {
                signSex = data.data.signsex;
				_this.updateDOM(data.data);
				$('.popup2.popup-programs .program.qr img').attr('src', data.data.fileName);
				if (typeof callback == 'function') callback(data)
			} else if (data.code == '990001'){
				window.location.href = "./logIn/index.html";
			} else {
				headtipObj.show(data.message);
			}
			if(data.data.collectpower == '1'){
                $('.content_list>a:eq(2)').children('.hot-container').show();
                // $('.content_list>a:eq(2)').click(function () {
                //     $(this).attr('href','speeDdubbing.html?demand=4');
                // });
                $('.service_option:eq(2)').removeClass('disabled');
                // $('.service_option:eq(2)>a').click(function () {
                //     $(this).attr('href','speeDdubbing.html?demand=4');
                // });
			} else {
                $('.content_list>a:eq(2)').children('.hot-container').hide();
                $('.content_list>a:eq(2)').click(function () {
                    $(this).attr('href','empty.html?type=4')
                });
                $('.service_talk_wrap .service_option:eq(2)').addClass('disabled');
                $('#right-nav .service_option:eq(2)').addClass('disabled');
                // $('.service_talk_wrap .service_option:eq(2)>a').click(function () {
                //     $(this).attr('href','empty.html?type=4')
                // })
                // $('#right-nav .service_option:eq(2)').click(function () {
                //     $(this).attr('href','empty.html?type=4')
                // })
            }
		})
	},
	// 更新dom
	updateDOM: function (data) {
		$('.user_img.header_item .img-container img').get(0).src = data.media_pic;
		this.$container.html(this.render(data));
		if (typeof this.callback == 'function') this.callback(data);
	},
	render: function (data) {
        var html = "<ul><li class='font1 first-line'><span class='font'>" + data.media_name + "</span><span class='token-switch'>切换<img src='img/icon-switch.png'></span></li><li class='line'></li><li class='font2'><span class='font'>基础版</span><a class='font font3' style='display: inline-block;' target='_blank' href='http://www.soundems.com/price.html'>升级</a></li><li class='font1 mineEmail'><span class='font'>"+data.email+"</span></li><li class='line'></li><li class='hover point font5 event-none'><a href='setting.html' class='gotourl'><span class='font'>账号设置</span></a></li><li class='line'></li><li class='hover point font5 feedback'><a href='feedback.html'><span class='font'>意见反馈</span></a></li><li class='hover point font5 invite'><span class='font'>分享音频</span></li><li class='hover point font5 event-none'><a href='http://www.soundems.com/quality.html' target='_blank' class='gotourl'><span class='font'>质量政策</span></a></li><li class='hover point font5 help-item'><span class='font'>使用帮助</span></li><li class='line'></li><li class='hover point font5 logout'><span class='font'>退出登录</span></li></ul>";
		return html;
	},
	show: function () {
		this.$container.show();
	},
	close: function () {
		this.$container.hide();
	}
};

// personInfo.init(callback);


var programSelect = {
	$container: $('.popup2.popup-programs'),
	init: function () {
		this.bindClose();
		this.bindSwitch();
		this.delegateShow();
	},
	delegateShow: function () {
		var _this = this;
		$('.boxShow.mine').delegate('.invite', 'click', function () {
			_this.show(1);
		})
	},
	bindSwitch: function () {
		var _this = this;
		this.$container.find('.nav > div').click(function (e) {
			var $this = $(this);
			var type = $this.data('type');
			_this.show(type);
		})
	},
	bindClose: function () {
		var _this = this;
		this.$container.find('.close').click(function () {
			console.log(1);
			_this.close();
		})
	},
	show: function (type) {
		this.$container.removeClass('hide');
		this.$container.find('.nav > div[data-type="' + type + '"]').addClass('active')
			.siblings().removeClass('active');
		this.$container.find('.program[data-type="' + type + '"]').removeClass('hide')
			.siblings().addClass('hide');
	},
	close: function () {
		this.$container.addClass('hide');
	}
};
programSelect.init();


// 收藏主播按钮
$('.contentLeft .left_list a.mark').click(function (e) {
	e.preventDefault();
	headtipObj2.show('该功能仅对高级版/企业版充值用户开放');
});

$('.left-nav a.mark').click(function (e) {
	e.preventDefault();
	headtipObj2.show('该功能仅对高级版/企业版充值用户开放');
});
serveFunc = {
	$container: $('.boxShow.server'),
	init: function () {
		this.bindHover();
		this.bindQQ();
	},
	hoverHTML: '<img src="img/server (1).png" alt=""><span>电话客服</span>',
	bindHover: function () {
		var _this = this;
		this.$container.find('.btn.phoneServer').on('mouseover', function () {
			var $this = $(this);
			$this.text('15321760535');
		});
		this.$container.find('.btn.phoneServer').on('mouseleave', function () {
			var $this = $(this);
			$this.html(_this.hoverHTML);
		})
	},
	bindQQ: function () {
		this.$container.find('.QQServer.btn').click(function () {
			window.open('http://wpa.qq.com/msgrd?v=3&uin=574823458&site=qq&menu=yes','_blank');
		})
	}
};
serveFunc.init();
$('.headerRight .info_logo.header_item').click(function () {
	headtipObj2.show('您还没有收到任何通知');
});
//文本ie取消富文本
$('[contenteditable]').each(function() {
    // 干掉IE http之类地址自动加链接
    try {
        document.execCommand("AutoUrlDetect", false, false);
    } catch (e) {}

    $(this).on('paste', function(e) {
        e.preventDefault();
        var text = null;

        if(window.clipboardData && clipboardData.setData) {
            // IE
            text = window.clipboardData.getData('text');
        } else {
            text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('在这里输入文本');
        }
        if (document.body.createTextRange) {
            if (document.selection) {
                textRange = document.selection.createRange();
            } else if (window.getSelection) {
                sel = window.getSelection();
                var range = sel.getRangeAt(0);

                // 创建临时元素，使得TextRange可以移动到正确的位置
                var tempEl = document.createElement("span");
                tempEl.innerHTML = "&#FEFF;";
                range.deleteContents();
                range.insertNode(tempEl);
                textRange = document.body.createTextRange();
                textRange.moveToElementText(tempEl);
                tempEl.parentNode.removeChild(tempEl);
            }
            textRange.text = text;
            textRange.collapse(false);
            textRange.select();
        } else {
            // Chrome之类浏览器
            document.execCommand("insertText", false, text);
        }
    });
    // 去除Crtl+b/Ctrl+i/Ctrl+u等快捷键
    $(this).on('keydown', function(e) {
        // e.metaKey for mac
        if (e.ctrlKey || e.metaKey) {
            switch(e.keyCode){
                case 66: //ctrl+B or ctrl+b
                case 98:
                case 73: //ctrl+I or ctrl+i
                case 105:
                case 85: //ctrl+U or ctrl+u
                case 117: {
                    e.preventDefault();
                    break;
                }
            }
        }
    });
});
$('.text-wrapper').on('input property',function () {
	if ($(this).children().prop('tagName')=='IMG'){
		headtipObj.show('内容不允许添加图片，请重新输入');
		$(this).text('');
		$('.footer_word_num').text('0')
	}
});
